<!DOCTYPE html>
<html lang="en">
<head>
	<meta charset="UTF-8">
	<title>Document</title>
	<script type="text/javascript">
	window.onload = function (){
		var oText = document.getElementById('text1');
		var oUl = document.getElementById('ul1');

		
		/*oText.onkeyup = function (ev){			//是以这个开头的
			var ev = ev || event;
			if (ev.keyCode == 13) {				//回车
				var oLi = document.createElement('li');
				oLi.innerHTML = this.value;
				if ( oUl.children[0] ) {
					oUl.insertBefore(oLi, oUl.children[0])
				} else{
					oUl.appendChild( oLi );
				};
			};
		}*/

		oText.onkeyup = function (ev){			//ctrl + enter组合键发送
			var ev = ev || event;
			if (ev.keyCode == 13 && ev.ctrlKey) {
				var oLi = document.createElement('li');
				oLi.innerHTML = this.value;
				if ( oUl.children[0] ) {
					oUl.insertBefore(oLi, oUl.children[0])
				} else{
					oUl.appendChild( oLi );
				};
			};
		}
	}
	</script>
</head>
<body>
	<input id="text1" type="text" />
	<ul id="ul1"></ul>
	<p>点击回车发送</p>
	<p>点击ctrl+回车发送</p>
</body>
</html>